package com.zige.zige.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.TextView;

import com.zige.zige.R;

/**
 * Created by user on 2016/3/19.
 */
public class ErrorMsgActivity extends BaseActivity {

    private Handler mHandler =new Handler(){
        @Override
        public void handleMessage(Message msg) {
            exit();
        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_error_message);
        String message  = getIntent().getExtras().getString("message");
        TextView tvMsg = (TextView) findViewById(R.id.tv_prompt_content);
        tvMsg.setText(message);
        mHandler.sendEmptyMessageDelayed(1,1500);
    }


    private void exit(){
        finish();
        overridePendingTransition(0, R.anim.error_msg_out);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        exit();
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(keyCode == KeyEvent.KEYCODE_BACK){
            exit();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
